/**
 * Created by Administrator on 2017/6/28.
 */


module.exports = function(app) {
    return new Handler(app);
};

var Handler = function(app) {
    this.app = app;
};

var handler = Handler.prototype;

function RegisterHandler(name) {
    handler[name] = function(msg, session, next) {
        var room = session.room;

        var roomHandler = room["handle" + name.capWord()];
        if (!roomHandler || typeof (roomHandler) != 'function') {
            next(null, {code: Code.GAME_ROUTE_INVALID}); return;
        }

        roomHandler.call(room, session.player, msg, function(resp) {
            next(null, resp);
        });
    }
}

RegisterHandler("PlayCards");
